<template>
  <div>
    <Row class="home-page-content" align="middle">
      <BtnPlain class="com-action-btn" type="primary" @click="goBack">返回</BtnPlain>
      <h3>经营信息{{type ==='view' ? '详情' : type ==='receive' ? '接收情况' : '反馈'}}</h3>
    </Row>

    <div class="home-page-content business-Info">
      <Row justify="space-between" align="middle">
        <Row align="middle">
          <BtnPlain v-if="info.auditStatus !== 'Pass'" class="com-action-btn" type="error">{{ info.auditStatusName }}</BtnPlain>
          <BtnPlain
            v-else
            class="com-action-btn"
            :type="info.acceptStatus | getAcceptStatus"
          >{{ info.acceptStatusName }}</BtnPlain>
        </Row>
        <div class="publisher">
          <span>发布人 {{ info.publisher || '--' }}</span>
          <span>发布时间 {{ info.publishTime || '--'}}</span>
        </div>
      </Row>
      <Row class="mt-20" align="middle" v-if="info.auditStatus === 'NotPass'">
        <h4>拒绝理由</h4>
        <span class="ml-20">{{ info.auditRemark }}</span>
      </Row>
      <Row class="mt-20" justify="space-between" align="middle">
        <h3>{{ info.projectName }}</h3>
        <BtnText v-if="page === 'myBusinessInfo'" type="primary" @BtnClick="goToHistory">变更历史记录</BtnText>
      </Row>
      <HistoryChange v-model="modelValueHistory" :busiInfoId="info.busiInfoId" />

      <!-- 经营信息 -->
      <BusinessInfo :info="info" v-if="type ==='view'" />

      <!-- 接收情况 -->
      <ReceiveList
        v-if="info.auditStatus === 'Pass'"
        :showFeedback="type !== 'receive'"
        :busiIndustryAssignList="info.busiIndustryAssignList"
      />

      <div v-else>
        <Divider />
        <h3>推送目标企业</h3>
        <div class="mt-20" v-for="(item, index) in info.busiIndustryAssignList" :key="index">
          <Row justify="space-between" align="middle" class="mb-10">
            <h4>{{ item.industryName }}</h4>
          </Row>
          <Table :columns="columnsCompany" :data="item.busiIndustryCompanyList"></Table>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import BusinessInfo from './common/businessInfo.vue'
import ReceiveList from './common/receiveList.vue'
import HistoryChange from '@/pages/components/historyChange'
import { busiInfoGetData } from '@/api/businessInformationManage.js'

export default {
  name: "businessInformationDetails",
  components: { BusinessInfo, ReceiveList, HistoryChange },
  data () {
    return {
      type: 'view',
      info: {},
      busiInfoId: '',
      columnsCompany: [
        {
          title: '公司名称',
          key: 'companyName',
        },
        {
          title: '推送方式',
          key: 'notificationWayName',
        }
      ],
      page: 'myBusinessInfo',
      modelValueHistory: false
    };
  },
  created () {
    const { busiInfoId, type, page } = this.$route.query
    this.type = type
    this.page = page || 'myBusinessInfo'
    this.busiInfoId = busiInfoId
    this.init(busiInfoId)
  },
  methods: {
    async init (busiInfoId) {
      this.info = await busiInfoGetData({ busiInfoId })
    },
    goBack () {
      this.$router.replace({ path: '/' + this.page });
    },
    goToHistory () {
      this.modelValueHistory = true
      // this.$router.push({ path: "/businessInfoHistory", query: { busiInfoId: this.busiInfoId, type: this.type } });
    }
  },
}
</script>

<style lang='less' scoped>
.business-Info {
  margin-top: 20px;
}

.publisher {
  > span {
    margin-left: 20px;
  }
}

.mt-20 {
  margin-top: 20px;
}

.ml-20 {
  margin-left: 20px;
}
.mb-10 {
  margin-bottom: 10px;
}
</style>
